package com.maycari.captainbi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.maycari.captainbi.data.dto.AuthorizationManagementDto;
import com.maycari.captainbi.data.po.AuthorizationManagementPo;
import com.maycari.captainbi.mapper.AuthorizationManagementDao;
import com.maycari.captainbi.service.AuthorizationManagementService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.maycari.tool.utils.BeanUtil;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 授权管理 服务实现类
 * </p>
 *
 * @author 王宏伟
 * @since 2021-04-12
 */
@Service
public class AuthorizationManagementServiceImpl extends ServiceImpl<AuthorizationManagementDao, AuthorizationManagementPo> implements AuthorizationManagementService {

    @Override
    public AuthorizationManagementDto selectById(Integer id) {
        return BeanUtil.copy(getById(id), AuthorizationManagementDto.class);
    }

    @Override
    public List<AuthorizationManagementDto> getAll() {
        LambdaQueryWrapper<AuthorizationManagementPo> la = new LambdaQueryWrapper<>();
        la.eq(AuthorizationManagementPo::getStatus, 1);
        return BeanUtil.copy(baseMapper.selectList(la), AuthorizationManagementDto.class);
    }
}
